import random
import os.path

def create_filename():
    filename_lst = []
    lst = ['水果', '烟酒', '粮油', '肉蛋', '蔬菜']
    code = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
    for i in range(1, 3001):
        filename = ''
        if i < 10:
            filename += '000' + str(i)
        elif i < 100:
            filename += '00' + str(i)
        elif i < 1000:
            filename += '0' + str(i)
        else:
            filename += str(i)
        # 拼接类别
        filename += '_' + random.choice(lst)
        # 拼接识别码
        s = ''
        for j in range(9):
            s += random.choice(code)
        filename += '_' + s
        filename_lst.append(filename)
    return filename_lst

# print(create_filename())

# 创建文件的函数
def create_file(filename):
    with open(filename, 'w') as file:
        pass

path = './data'

if not os.path.exists(path):
    os.mkdir(path)

lst = create_filename()  # 获取文件名的列表

for item in lst:
    create_file(os.path.join(path, item) + '.txt')